package com.mdb.log;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class LogAdapter {
	public static final Log RQ_LOG = new Log("rqlog");
	public static final Log DB_LOG = new Log("dblog");
	public static final Log RS_LOG = new Log("rslog");

	public static final void debugLine() {
		RQ_LOG.debug("--------------------------------------------------------------------------------", new Object[0]);
	}

	public static final class Log {
		private final Logger logger;
		private final Set<String> filterSet = new HashSet<String>();

		public Log(String logName) {
			this.logger = LoggerFactory.getLogger(logName);
		}

		public void addAll(String splitContent) {
			this.filterSet.addAll(Arrays.asList(splitContent.split(",")));
		}

		public final void info(String format, Object[] arguments) {
			this.logger.info(format, arguments);
		}

		public final void warn(String format, Object[] arguments) {
			this.logger.warn(format, arguments);
		}

		public final boolean isDebugEnabled() {
			return this.logger.isDebugEnabled();
		}

		public final boolean isDebugEnabled(String name) {
			return (this.logger.isDebugEnabled()) && (!this.filterSet.contains(name));
		}

		public final void debug(String format, Object[] arguments) {
			this.logger.debug(format, arguments);
		}

		public final void debugLine() {
			this.logger.debug("--------------------------------------------------------------------------------");
		}
	}
}